package com.songlanyun.modules.order.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.songlanyun.common.validator.ValidatorUtils;
import org.springframework.stereotype.Service;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.songlanyun.common.utils.PageUtils;
import com.songlanyun.common.utils.Query;

import com.songlanyun.modules.order.dao.OrderUserKeyDao;
import com.songlanyun.modules.order.entity.OrderUserKey;
import com.songlanyun.modules.order.service.OrderUserKeyService;


@Service("orderUserKeyService")
public class OrderUserKeyServiceImpl extends ServiceImpl<OrderUserKeyDao, OrderUserKey> implements OrderUserKeyService {


    @Override
    public OrderUserKey create(OrderUserKey entity) {
        ValidatorUtils.validateEntity(entity);
        this.baseMapper.insert(entity);
        return entity;
    }

    @Override
    public OrderUserKey modify(OrderUserKey entity) {
        ValidatorUtils.validateEntity(entity);
        this.baseMapper.updateById(entity);
        return entity;
    }

    @Override
    public void remove(Long id) {
        this.baseMapper.deleteById(id);
    }

    /**
     * 会员删除订单时实际对自己的钥匙做软删除
     * @param orderId
     * @param userId
     */
    @Override
    public void  removeByOrderId(Long orderId,Long userId)
    {
        this.baseMapper.delete(
                new LambdaQueryWrapper<OrderUserKey>()
                        .eq(OrderUserKey::getOrderId,orderId)
                        .eq(OrderUserKey::getUserId,userId));
    }

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        return null;
    }
}